package cn.ante.ymcc.web.controller;

import cn.ante.ymcc.dto.RegisterDto;
import cn.ante.ymcc.result.JSONResult;
import cn.ante.ymcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeService verifyCodeService;


    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult graph(@PathVariable("imageCodeKey") String imageCodeKey){
        String base64Str = verifyCodeService.graph(imageCodeKey);
        return JSONResult.success(base64Str);
    }

    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody @Valid RegisterDto dto){
        JSONResult jsonResult = verifyCodeService.sendSmsCode(dto);
        return JSONResult.success(jsonResult);
    }
}
